package com.atwulidun.factory02.simplefactory.order;


import com.atwulidun.factory02.simplefactory.pizza.CheesePizza;
import com.atwulidun.factory02.simplefactory.pizza.GreekPizza;
import com.atwulidun.factory02.simplefactory.pizza.Pizza;

//简单工厂类
public class SimpleFactory {

    // 根据 orderType 返回对应的 Pizza 对象
    public Pizza createPizza(String orderType) {
        Pizza pizza = null;
        System.out.println("使用简单工厂模式(实例方法)");
        if (orderType.equals("greek")) {
            pizza = new GreekPizza(" 希腊披萨 ");
        } else if (orderType.equals("cheese")) {
            pizza = new CheesePizza(" 奶酪披萨 ");
        }
        return pizza;
    }

    // 简单工厂模式 也叫 静态工厂模式
    public static Pizza createPizza1(String orderType) {
        Pizza pizza = null;
        System.out.println("使用简单工厂模式(静态方法)");
        if (orderType.equals("greek")) {
            pizza = new GreekPizza(" 希腊披萨 ");
        } else if (orderType.equals("cheese")) {
            pizza = new CheesePizza(" 奶酪披萨 ");
        }
        return pizza;
    }
}
